package us.congcong.rsshunter.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import us.congcong.rsshunter.service.ToutiaoRssService;

import java.util.Map;

@Api(value = "Rss服务",description="提供关头条等RSS服务")
@Controller
@RequestMapping("/toutiaorss")
public class ToutiaoRssController {
	 @Autowired
    private  ToutiaoRssService toutiaoRssService;

     @ApiOperation("根据头条RSS")
     @RequestMapping(value="/index",method = RequestMethod.GET)
     public ModelAndView index() {
    	 Map info = toutiaoRssService.produceRss();
    	 if(info == null){
    		 return null;
    	 }
    	 ModelAndView mav = new ModelAndView();
         mav.setViewName("RSSFeedViewer");
         mav.addObject("feedChannel", info.get("channel"));
         mav.addObject("feedContent", info.get("items"));
         return mav;
     }
}